home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / languages / brainfuck-2.lha / README < prev   
Encoding:
Text File  |  1993-06-09  |  2.8 KB  |  74 lines

  1. This archive contains the following programs:
  2.  
  3.  bfc          The compiler for the 'brainfuck' language (240 bytes!)
  4.  bfc.asm      Source for the compiler
  5.  bfi          The interpreter for the 'brainfuck' language
  6.  bfi.c        Source for the interpreter (portable)
  7.  src/         Some example programs in 'brainfuck'
  8.  src/atoi.b   Reads a number from stdin
  9.  src/div10.b  Divides the number under the pointer by 10
  10.  src/hello.b  The ubiquitous "Hello World!"
  11.  src/mul10.b  Multiplies the number under the pointer by 10
  12.  src/prime.b  Computes the primes up the a variable limit
  13.  src/varia.b  Small program elements like SWAP, DUP etc.
  14.  
  15.  
  16. WHATS NEW
  17. =========
  18.  
  19. Yes, I squeezed another ridiculous 56 bytes out of the compiler. They have
  20. their price, though: The new compiler requires OS 2.0, operates on a byte 
  21. array instead of longwords, and generates executables that are always 64K 
  22. in size. Apart from that the language hasn't changed. Again:
  23. ***  OS 2.0 *required* for the compiler and the compiled programs  *** 
  24. The interpreter works fine under any OS version. And yes, thanks to Chris
  25. Schneider for his ideas how to make the compiler shorter.
  26.  
  27.  
  28. THE LANGUAGE
  29. ============
  30.  
  31. The language 'brainfuck' knows the following commands:
  32.  
  33.  Cmd  Effect                                 Equivalent in C
  34.  ---  ------                                 ---------------
  35.  +    Increases element under pointer        array[p]++;
  36.  -    Decrases element under pointer         array[p]--;
  37.  >    Increases pointer                      p++;
  38.  <    Decreases pointer                      p--;
  39.  [    Starts loop, counter under pointer     while(array[p]) {
  40.  ]    Indicates end of loop                  }
  41.  .    Outputs ASCII code under pointer       putchar(array[p]);
  42.  ,    Reads char and stores ASCII under ptr  array[p]=getchar();
  43.  
  44. All other characters are ignored. The 30000 array elements and p are being
  45. initialized to zero at the beginning.  Now while this seems to be a pretty
  46. useless language, it can be proven that it can compute every solvable
  47. mathematical problem (if we ignore the array size limit and the executable
  48. size limit).
  49.  
  50.  
  51. THE COMPILER
  52. ============
  53.  
  54. The compiler does not check for balanced brackets; they better be. It reads
  55. the source from stdin and writes the executable to stdout. Note that the 
  56. executable is always 65536 bytes long, and usually won't be executable if
  57. brackets aren't balanced. OS 2.0 required for the compiler and the compiled
  58. program.
  59.  
  60.  
  61. THE INTERPRETER
  62. ===============
  63.  
  64. For debugging, there's also an interpreter. It expects the name of the 
  65. program to  interpret on the command line and accepts an additional command:
  66. Whenever a '#' is met in the source and a second argument was passwd to
  67. the interpreter, the first few elements of the array are written to stdout
  68. as numbers
  69.  
  70.  
  71.    Enjoy
  72.  
  73.      -Urban Mueller     <umueller@amiga.physik.unizh.ch>
  74.